//
//  STMainPageService.m
//  YiYueStore
//
//  Created by zhouzhouzhou on 2018/10/16.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STMainPageService.h"
#import "STNetRequset.h"
#import "NSDictionary+ZYHTestFormat.h"

#define requestIP BASEURL

#define requestIP2 BASEURL //@"http://192.168.0.199:8021"
#define requestIP3 BASEURL //@"http://192.168.0.161:8021"

#define requestIP4 BASEURL //@"http://192.168.0.187:8090/stylist-api"

//门店和美发师的接口名不同
#ifdef YIYUEHAIRDRESSER

//美发师详情
static NSString * const hairerInfoUrl = @"stylistCard/card";
//美发师评价
static NSString * const hairerEvaUrl = @"stylistOrderCount/getEvaluate";

//美发师作品详情
static NSString * const hairerOpusInfoUrl = @"stylistCard/opusDetail";
//美发师作品集
static NSString * const hairerOpusListUrl = @"stylistCard/opusList";
//美发师作品转发 浏览统计
static NSString * const hairerOpusCountUrl = @"stylistCard/opusCount";
//美发师评论列表
static NSString * const commentListUrl = @"stylistComment/getStylistCommentList";
//根据订单id查询评论
static NSString * const getOrderCommenUrl = @"stylistOrderCount/getOrderComment";

//回复评论
static NSString * const replayCommentUrl = @"stylistComment/replyStylistComment";
#else

static NSString * const hairerInfoUrl = @"storeStylist/card";
static NSString * const hairerOpusInfoUrl = @"storeStylist/opusDetail";
static NSString * const hairerOpusListUrl = @"storeStylist/opusList";
static NSString * const hairerOpusCountUrl = @"storeStylist/opusCount";
static NSString * const commentListUrl = @"storeComment/getStoreCommentList";
static NSString * const replayCommentUrl = @"storeComment/replyStoreComment";

#endif
//获取门店审核状态URL
 static NSString * const doorExamineStatusUrl = @"storeAuthApply/getStoreAuthApplyBystylistId";

//请求地理位置URL
 static NSString * const doorInfoStoreInfoUrl1 = @"storeManage/getStoreInfo";

//请求签约美发师URL
 static NSString * const doorInfoStoreInfoUrl2 = @"storeManage/getNexusStyScrool";

//请求门店服务范围URL
 static NSString * const doorInfoStoreInfoUrl3 = @"storeManage/getStoreServerScope";

//请求顾客评价URL
static NSString * const doorInfoStoreInfoUrl4 = @"storeManage/getStoreScore";
//查询当前门店，技师申请状态URL
static NSString * const doorInfoGetNexuStatusUrl5 = @"joinStore/getNexuStatus";

//请求服务器城市数据
static NSString * const cityInfoUrl = @"area/getArea";
//请求服务器城市数据
static NSString * const cityAreaInfoUrl1 = @"area/getAreaByPartentId";
//请求服务器城市数据
static NSString * const cityAreaInfoUrl2 = @"area/getAreaBystylistId";

//附近查询
static NSString * const hairerNearUrl = @"storeStylist/inviteNear";
//排序查询
static NSString * const hairerSortUrl = @"storeStylist/inviteSort";
//筛选查询
static NSString * const hairerScreenUrl = @"storeStylist/inviteScreen";

//
//门店邀请美发师
static NSString * const inviteHairerUrl = @"storeStylist/inviteNexus";


//订单统计
static NSString * const orderCount = @"storeOrder/getStoreOrderCount";
//门店所有成功订单统计
static NSString * const orderCountStoreSuccessUrl = @"storeOrder/getStoreSuccessCount";
//美发师的成功订单统计
static NSString * const orderCountHairUrl = @"storeOrder/getStoreSuccessOrders";
//扫码核销
static NSString * const scanQRCodeURL = @"verification/order";

static NSString * const updateCollectionTypeURL = @"storeManage/updateCollectionType";
static NSString * const getstoreSettingURL = @"store/getstoreSetting";
static NSString * const storeSettingURL = @"store/setting";
static NSString * const storeStoreStylistURL = @"store/storeStylist";
static NSString * const storeInviteSearchURL = @"storeStylist/inviteSearch";
static NSString * const storeOpusCollectionURL = @"storeStylist/opusCollection";
static NSString * const storeStoreCollectionURL = @"store/storeCollection";
static NSString * const storeBreakStoreNexusURL = @"store/breakStoreNexus";

@implementation STMainPageService


//获取门店审核状态
+(void)getDoorExamineStatusWithstylistId:(long)stylistId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    NSString * url =[requestIP stringByAppendingString:doorExamineStatusUrl];
    [STNetRequset netGetRequestWithUrlStr:url withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicData = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicData,error);
        
    }];
}

+(void)getDoorInfoWithParameters:(NSDictionary *)parameters completion:(STResultObjectBlock)completion{
    __block NSDictionary * dicLocalInfo;
    __block NSDictionary * dicHairerInfo;
    __block NSDictionary * dicServiceInfo;
    __block NSDictionary * dicCommonInfo;
    __block NSDictionary * dicGetNexuStatusInfo;
    __block NSError * oneError;
    dispatch_group_t group = dispatch_group_create();
    
    YLUserInfo * userInfo = [YLUserInfo sharedInstance];
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    [dicParameters setValue:[NSNumber numberWithDouble:userInfo.selfLongitude] forKey:@"lng"];
    [dicParameters setValue:[NSNumber numberWithDouble:userInfo.selfLatitude] forKey:@"lat"];
    //请求地理位置
    dispatch_group_enter(group);
    NSString * getStoreInfo =[requestIP stringByAppendingString:doorInfoStoreInfoUrl1];
    NSString * getNexusStyScrool =[requestIP stringByAppendingString:doorInfoStoreInfoUrl2];
    NSString * getStoreServerScope =[requestIP stringByAppendingString:doorInfoStoreInfoUrl3];
    NSString * getStoreScore =[requestIP stringByAppendingString:doorInfoStoreInfoUrl4];
    NSString * getGetNexuStatus =[requestIP stringByAppendingString:doorInfoGetNexuStatusUrl5];
    
    [STNetRequset netPostRequestWithUrlStr:getStoreInfo withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicLocalInfo = [NSDictionary dictionaryWithDictionary:result[@"data"]];
        }
        if (error) {
            oneError = error;
        }
        dispatch_group_leave(group);

    }];
    //请求签约美发师
    dispatch_group_enter(group);
    
    NSMutableDictionary *hairdic = [NSMutableDictionary dictionary];
    NSString *nexus = [NSString stringWithFormat:@"%@",[dicParameters objectForKey:@"nexus"]];
    NSString *storeId = [NSString stringWithFormat:@"%@",[dicParameters objectForKey:@"storeId"]];
    [hairdic setObject:nexus forKey:@"nexus"];
    [hairdic setObject:storeId forKey:@"storeId"];
    [hairdic setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    
    [STNetRequset netPostRequestWithUrlStr:getNexusStyScrool withParameters:hairdic completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        if ([dicResult.allKeys containsObject:@"data"]) {
            NSArray * arrHairs = [NSArray arrayWithArray:dicResult[@"data"]];
            dicHairerInfo = @{@"hairers":arrHairs};
        }
        if (error) {
            oneError = error;
        }
        dispatch_group_leave(group);
    }];
    //请求门店服务范围
    dispatch_group_enter(group);
    [STNetRequset netGetRequestWithUrlStr:getStoreServerScope withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicServiceInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        if (error) {
            oneError = error;
        }
        dispatch_group_leave(group);
    }];
    //请求顾客评价
    dispatch_group_enter(group);
    [STNetRequset netGetRequestWithUrlStr:getStoreScore withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        if (error) {
            oneError = error;
        }
        dispatch_group_leave(group);
    }];

    //查询当前门店，技师申请状态
    dispatch_group_enter(group);
    [STNetRequset netGetRequestWithUrlStr:getGetNexuStatus withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicGetNexuStatusInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        if (error) {
            oneError = error;
        }
        dispatch_group_leave(group);
    }];
    
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        //界面刷新
        NSMutableDictionary * dicDoorInfo = [NSMutableDictionary dictionaryWithCapacity:4];
        [dicDoorInfo setValue:dicLocalInfo forKey:@"localInfo"];
        [dicDoorInfo setValue:dicHairerInfo[@"hairers"] forKey:@"hairerInfos"];
        [dicDoorInfo setValue:dicServiceInfo forKey:@"serviceInfo"];
        [dicDoorInfo setValue:dicCommonInfo forKey:@"commonInfo"];
        [dicDoorInfo setValue:dicGetNexuStatusInfo forKey:@"getNexuStatus"];
        
        completion(dicDoorInfo,oneError);
    });
}


//将门店添加收藏
+(void)collectionDoorWithstylistId:(long)stylistId isCollection:(BOOL)collection completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithBool:collection] forKey:@"stylistId"];
    
    NSString * updateCollectionType =[requestIP stringByAppendingString:updateCollectionTypeURL];
    [STNetRequset netPostRequestWithUrlStr:updateCollectionType withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dic = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicResult;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicResult = [NSDictionary dictionaryWithDictionary:dic[@"data"]];
        }
        completion(dicResult,error);
    }];
}


//获取门店总评分
+(void)getDoorTotalScoreWithstylistId:(long)stylistId completion:(STResultObjectBlock)completion{
    
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].token forKey:@"Token"];
    NSString * getStoreScore =[requestIP stringByAppendingString:doorInfoStoreInfoUrl4];
    [STNetRequset netGetRequestWithUrlStr:getStoreScore withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


//获取门店所有服务类型
+(void)getDoorAllServiceType:(STResultObjectBlock)completion{
    [PersonCenterNet  getserviceListWithSuccess:^(NSURLSessionTask *task, id responseObject) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:responseObject];
        NSArray * arrDatas;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrDatas = [NSArray arrayWithArray:dicResult[@"data"]];
            completion(arrDatas,nil);
        }
    } Failure:^(NSURLSessionTask *task, NSError *error) {
        completion(nil,error);
    }];
}

//获取门店服务设置信息
+(void)getDootSetInfoWithstylistId:(long)stylistId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    NSString * getStoreCommentList =[requestIP stringByAppendingString:getstoreSettingURL];
    [STNetRequset netPostRequestWithUrlStr:getStoreCommentList withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

//设置门店服务设置信息
+(void)setDootSetInfoWithstylistId:(long)stylistId WithParameters:(NSDictionary *)parameters completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    NSString * getStoreCommentList =[requestIP stringByAppendingString:storeSettingURL];
    [STNetRequset netPostRequestWithUrlStr:getStoreCommentList withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

#pragma mark- 评论

//根据订单id查询评论
+(void)getOrderCommentWithOrderId:(long)orderId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
    [dicParameters setValue:[NSNumber numberWithLong:orderId] forKey:@"orderId"];
    NSString * getOrderComment = [requestIP stringByAppendingString:getOrderCommenUrl];
    [STNetRequset netGetRequestWithUrlStr:getOrderComment withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


//获取门店评论 分页
+(void)getDoorCommentWithstylistId:(long)stylistId page:(int)page size:(int)size completion:(STResultObjectBlock)completion{
    
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    //TODO:用户单例信息
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"id"];
    [dicParameters setValue:[YLUserInfo sharedInstance].token forKey:@"Token"];
    [dicParameters setValue:[NSNumber numberWithInt:page] forKey:@"page"];
    [dicParameters setValue:[NSNumber numberWithInt:size] forKey:@"size"];
    NSString * getStoreCommentList =[requestIP stringByAppendingString:commentListUrl];
    [STNetRequset netGetRequestWithUrlStr:getStoreCommentList withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrCommonInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrCommonInfo,error);
        
    }];
}

//回复评论
+(void)replayDoorCommentWithCommentId:(long)commentId context:(NSString*)context completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:3];
    [dicParameters setValue:[NSNumber numberWithLong:commentId] forKey:@"stylistReviewsId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].token forKey:@"Token"];
    [dicParameters setValue:context forKey:@"context"];
    NSString * replyStoreComment =[requestIP stringByAppendingString:replayCommentUrl];
    [STNetRequset netPostRequestWithUrlStr:replyStoreComment withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


#pragma mark- 美发师
//获取美发师名片详情
+(void)getHairerInfo:(long)stylistId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID?:@"" forKey:@"userId"];
    
    NSString * card =[requestIP2 stringByAppendingString:hairerInfoUrl];
    [STNetRequset netPostRequestWithUrlStr:card withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


//获取美发师评价
+(void)getHairerEvaluate:(long)stylistId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    NSString * card =[requestIP stringByAppendingString:hairerEvaUrl];
    [STNetRequset netGetRequestWithUrlStr:card withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

//根据门店自己的 美发师列表
+(void)getSelfHairerListWithstylistId:(long)stylistId Type:(int)type page:(int)page size:(int)size completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithInt:type] forKey:@"nexus"];
    [dicParameters setValue:[NSNumber numberWithInt:page] forKey:@"page"];
    [dicParameters setValue:[NSNumber numberWithInt:size] forKey:@"size"];
    NSString * storeStylist =[requestIP stringByAppendingString:storeStoreStylistURL];
    [STNetRequset netPostRequestWithUrlStr:storeStylist withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrData = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrData,error);
        
    }];
}


//根据条件查询 美发师列表
+(void)nearbySortScreen:(int)type distance:(long)distance cityId:(long)cityId districtId:(int)districtId coupon:(NSString *)coupon position:(NSString *)position sortType:(int)sortType page:(int)page size:(int)size complection:(STResultObjectBlock)complection{
    if (type ==1) {
        [STMainPageService getHairerListWithDistance:distance cityId:cityId districtId:districtId page:page size:size completion:^(id result, NSError *error) {
            complection(result,error);
        }];
    }else if (type ==2) {
        [STMainPageService getHairerListWithSortType:sortType page:page size:size completion:^(id result, NSError *error) {
             complection(result,error);
        }];
    }else if (type ==3) {
        [STMainPageService getHairerListWithCoupon:coupon position:position page:page size:size completion:^(id result, NSError *error) {
            complection(result,error);
        }];
    }
}

//附近查询
+(void)getHairerListWithDistance:(long)distance cityId:(long)cityId districtId:(long)districtId page:(int)page size:(int)size completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    if(distance != 0){
        [dicParameters setValue:[NSNumber numberWithDouble:distance] forKey:@"distance"];
    }
    if(cityId != 0){
        [dicParameters setValue:[NSNumber numberWithLong:cityId] forKey:@"cityId"];
    }
    if(districtId != 0){
        [dicParameters setValue:[NSNumber numberWithLong:districtId] forKey:@"districtId"];
    }
    [dicParameters setValue:[NSNumber numberWithInt:page] forKey:@"page"];
    [dicParameters setValue:[NSNumber numberWithInt:size] forKey:@"size"];
    NSString * inviteNear =[requestIP stringByAppendingString:hairerNearUrl];

    [STNetRequset netPostRequestWithUrlStr:inviteNear withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrData = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrData,error);
        
    }];
}


//排序查询
+(void)getHairerListWithSortType:(int)sortType page:(int)page size:(int)size completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithInt:sortType] forKey:@"sortType"];
    [dicParameters setValue:[NSNumber numberWithInt:page] forKey:@"page"];
    NSString * inviteNear =[requestIP stringByAppendingString:hairerSortUrl];
    [STNetRequset netPostRequestWithUrlStr:inviteNear withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrData = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrData,error);
        
    }];
}

//筛选查询
+(void)getHairerListWithCoupon:(NSString *)coupon position:(NSString *)position page:(int)page size:(int)size completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    [dicParameters setValue:coupon forKey:@"coupon"];
    [dicParameters setValue:position forKey:@"position"];
    [dicParameters setValue:[NSNumber numberWithInt:page] forKey:@"page"];
    NSString * inviteNear =[requestIP stringByAppendingString:hairerScreenUrl];
    [STNetRequset netPostRequestWithUrlStr:inviteNear withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrData = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrData,error);
        
    }];
}

//搜索美发师
+(void)searchHairerWithstylistId:(long)stylistId withName:(NSString *)name completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:2];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:name forKey:@"name"];
    NSString * inviteSearch =[requestIP stringByAppendingString:storeInviteSearchURL];
    [STNetRequset netPostRequestWithUrlStr:inviteSearch withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrData;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrData = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrData,error);
        
    }];
}

//获取美发师作品详情
+(void)searchHairerWithOpusId:(long)opusId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:opusId] forKey:@"opusId"];
    NSString * opusDetail =[requestIP stringByAppendingString:hairerOpusInfoUrl];
    [STNetRequset netPostRequestWithUrlStr:opusDetail withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

//获取美发师作品集
+(void)searchHairerWithStylistId:(long)stylistId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    NSString * opusList =[requestIP stringByAppendingString:hairerOpusListUrl];
    [STNetRequset netPostRequestWithUrlStr:opusList withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

//收藏/取消收藏美发师作品
+(void)collectionHairerProjectWithOpusId:(long)opusId type:(int)type completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:opusId] forKey:@"opusId"];
    [dicParameters setValue:[NSNumber numberWithInt:type] forKey:@"type"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    NSString * opusCollection =[requestIP stringByAppendingString:storeOpusCollectionURL];
    [STNetRequset netPostRequestWithUrlStr:opusCollection withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


//收藏/取消收藏美发师
+(void)collectionHairerWithStylistId:(long)stylistId type:(int)type completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithInt:type] forKey:@"type"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    NSString * storeCollection =[requestIP stringByAppendingString:storeStoreCollectionURL];
    [STNetRequset netPostRequestWithUrlStr:storeCollection withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
    }];
}

//门店解约美发师
+(void)relieveHairerWithStylistId:(long)stylistId nexus:(int)nexus completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:2];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithInt:nexus] forKey:@"nexus"];
    NSString * breakStoreNexus =[requestIP stringByAppendingString:storeBreakStoreNexusURL];
    [STNetRequset netPostRequestWithUrlStr:breakStoreNexus withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}


//门店邀请美发师
+(void)inviteHairerWithStylistId:(long)stylistId stylistUserId:(long)stylistUserId nexus:(int)nexus completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:5];
    [dicParameters setValue:[NSNumber numberWithLong:stylistId] forKey:@"stylistId"];
    [dicParameters setValue:[NSNumber numberWithLong:stylistUserId] forKey:@"stylistUserId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    [dicParameters setValue:[NSNumber numberWithInt:nexus] forKey:@"nexus"];
    NSString * breakStoreNexus =[requestIP stringByAppendingString:inviteHairerUrl];
    [STNetRequset netPostRequestWithUrlStr:breakStoreNexus withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}




//美发师作品 被查看/收藏统计
+(void)countHairerProjectWithOpusId:(long)opusId type:(int)type completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:4];
    [dicParameters setValue:[NSNumber numberWithLong:opusId] forKey:@"opusId"];
    [dicParameters setValue:[NSNumber numberWithInt:type] forKey:@"type"];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"userId"];
    NSString * opusCount =[requestIP stringByAppendingString:hairerOpusCountUrl];
    [STNetRequset netPostRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicCommonInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicCommonInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicCommonInfo,error);
        
    }];
}

#pragma mark 位置
+(void)getAllCityInfo:(STResultObjectBlock)completion{
    NSString * opusCount =[requestIP stringByAppendingString:cityInfoUrl];
    [STNetRequset netGetRequestWithUrlStr:opusCount withParameters:nil completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrInfo,error);
    }];
}

////获取城市区
//+(void)getCityAreasWithPartentId:(long)partentId completion:(STResultObjectBlock)completion{
//    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
//    [dicParameters setValue:[NSNumber numberWithLong:partentId] forKey:@"partentId"];
//    
//    NSString * opusCount =[requestIP stringByAppendingString:cityAreaInfoUrl1];
//    [STNetRequset netPostRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
//        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
//        NSArray * arrInfo;
//        if ([dicResult.allKeys containsObject:@"data"]) {
//            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
//        }
//        completion(arrInfo,error);
//    }];
//}

//根据门店id 获取城市区
+(void)getCityAreas:(STResultObjectBlock)completion{
    
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    NSString * opusCount =[requestIP3 stringByAppendingString:cityAreaInfoUrl2];
    [STNetRequset netPostRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrInfo,error);
    }];
}



+(void)getAllCityAreas:(STResultObjectBlock)completion{
    
    NSString * opusCount =[requestIP4 stringByAppendingString:cityInfoUrl];
    [STNetRequset netGetRequestWithUrlStr:opusCount withParameters:nil completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrInfo,error);
    }];
}
#pragma mark 订单统计
//订单统计
+(void)getStoreOrderCount:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:1];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"id"];
    NSString * opusCount =[requestIP stringByAppendingString:orderCount];
    [STNetRequset netGetRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSDictionary * dicInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            dicInfo = [NSDictionary dictionaryWithDictionary:dicResult[@"data"]];
        }
        completion(dicInfo,error);
    }];
}
//门店所有成功订单统计

+(void)getStoreSuccessCountWithStartStr:(NSString *)startStr endStr:(NSString *)endStr nexus:(int)nexus completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:3];
    [dicParameters setValue:[YLUserInfo sharedInstance].userID forKey:@"id"];
    [dicParameters setValue:startStr forKey:@"startTime"];
    [dicParameters setValue:endStr forKey:@"endTime"];
    [dicParameters setValue:[NSNumber numberWithInt:nexus] forKey:@"nexus"];
    NSString * opusCount =[requestIP stringByAppendingString:orderCountHairUrl];
    [STNetRequset netGetRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrInfo,error);
    }];
}



//扫码核销
+(void)scanQRcode:(NSString *)orderId completion:(STResultObjectBlock)completion{
    NSMutableDictionary * dicParameters = [NSMutableDictionary dictionaryWithCapacity:2];
    [dicParameters setValue:[YLUserInfo sharedInstance].stylistId forKey:@"stylistId"];
    [dicParameters setValue:orderId forKey:@"orderId"];
    NSString * opusCount =[requestIP stringByAppendingString:scanQRCodeURL];
    [STNetRequset netPostRequestWithUrlStr:opusCount withParameters:dicParameters completion:^(id result, NSError *error) {
        NSDictionary * dicResult = [NSDictionary dictionaryWithDictionary:result];
        NSArray * arrInfo;
        if ([dicResult.allKeys containsObject:@"data"]) {
            arrInfo = [NSArray arrayWithArray:dicResult[@"data"]];
        }
        completion(arrInfo,error);
    }];
}





































@end
